package com.yingpai.fitness.adpter;

import android.support.annotation.LayoutRes;
import android.support.v4.app.Fragment;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yingpai.fitness.R;
import com.yingpai.fitness.entity.dynamic.DynamicHotAndCityBean;

import de.hdodenhof.circleimageview.CircleImageView;


public class DynamicHotAndCityRecyclerAdapter extends BaseQuickAdapter<DynamicHotAndCityBean.
        MapData.PageInfoData.ListData, BaseViewHolder> {

    private Fragment context;//上下文/fragment/activity

    public DynamicHotAndCityRecyclerAdapter(@LayoutRes int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, DynamicHotAndCityBean.MapData.PageInfoData.ListData item) {
        ImageView dynamic_hot_city_iv = helper.getView(R.id.dynamic_hot_city_iv);//图片


        Glide.with(helper.getConvertView().getContext())
                .load(item.getPhotoUrls())
                .placeholder(R.mipmap.default_small_bg)
                .error(R.mipmap.default_small_bg)
                .into(dynamic_hot_city_iv);
        helper.addOnClickListener(R.id.dynamic_hot_city_iv);//图片监听


        TextView topic_item_title = helper.getView(R.id.topic_item_title);//标题
        topic_item_title.setText(item.getThemeTitle());

        CircleImageView dynamic_hot_city_user_head_iv = helper.getView(R.id.dynamic_hot_city_user_head_iv);//某人头像

        Glide.with(helper.getConvertView().getContext())
                .load(item.getPublisherPhotoUrl())
//                .placeholder(R.mipmap.default_small_bg)
                .error(R.mipmap.default_small_bg)
                .into(dynamic_hot_city_user_head_iv);

        TextView topic_user_head_name = helper.getView(R.id.topic_user_head_name);
        topic_user_head_name.setText((CharSequence) item.getPublisherName());


        TextView topic_user_collect_count_tv = helper.getView(R.id.topic_user_collect_count_tv);
        topic_user_collect_count_tv.setText(item.getPraiseNo() + "");

        ImageView dynamic_hot_city_user_collect_iv = helper.getView(R.id.dynamic_hot_city_user_collect_iv);
        if (item.getIsPraised() == 0) {
            dynamic_hot_city_user_collect_iv.setImageResource(R.mipmap.bbs_like_no);
        } else {
            dynamic_hot_city_user_collect_iv.setImageResource(R.mipmap.bbs_like);
        }

    }


}
